JavaScript is a scripting language that runs applications (e.g., programs) inside of a sandbox. The sandbox is a security mechanism for separating running applications, and provides an isolated execution environment for the applications. There are numerous available JavaScript engines, each of which interprets and executes JavaScript (or ECMAScript) in a slightly different manner. Examples of such JavaScript engines include Spider Monkey®, V8® and Nitro®.
Applications that run inside of the JavaScript sandbox frequently need to store data or access data outside of the sandbox. For example, such applications may store an object's state in native code that underlies the sandbox. To enable an application inside of the sandbox to access data outside of the sandbox, the JavaScript engines provide functions that generate pointers to the data. The functions place the pointers into JavaScript objects that are placed inside of the JavaScript sandbox. However, with conventional JavaScript engines, the pointers lose their type information when the pointers are placed in the JavaScript object. These JavaScript engines do not provide any mechanism for automatically determining the types that private pointers should have, or for automatically assigning pointer types to private pointers. When the type information is lost, there is typically no guarantee when a pointer is later pulled outside of the sandbox that it is the same pointer that was placed into the sandbox. This can have negative effects with regards to security. To address the loss of type, application developers currently typically need to add code to perform type checking to the applications. This can be burdensome, and has a high error rate. Additionally, programmers may fail to add type checking to their code, which may introduce security weaknesses.